var rootPath = getRootPath();
$(function() {
	$.ajax({
		url : rootPath + "/user/queryMyIntegral",
		method : "GET",
		success : function(data) {
			$("#integral").empty();
			if(data.returnCode='0000'){
				$("#integral").html(data.returnObject.integral);
				$("#hIntegral").html(data.returnObject.maxIntegral);
			} else {
				$("#integral").html(0);
			}
		},
		error: function (jqXHR, textStatus, errorThrown) {
		},
		complete:function(){
		}
	});
	
	$('#flowTable').DataTable({
        "language": {
        	"lengthMenu": "每页 _MENU_ 条记录",
            "zeroRecords": " ",
            "info": "当前 _START_ 条到 _END_ 条 &nbsp;&nbsp;&nbsp;共 _TOTAL_ 条记录",
            "infoEmpty": "无记录",
            "infoFiltered": "",//(从 _MAX_ 条记录过滤)
            "search": "搜索",
            "processing": "载入中",
            "paginate": {
                "first": "首页",
                "previous": "上一页",
                "next": "下一页",
                "last": "尾页"
            }
        },
        serverSide: true,
        info: false,
        lengthChange: false,//是否允许用户改变表格每页显示的记录数
        ordering: false,//是否允许用户排序
        paging: true,//是否分页
        processing: true,
        searching: false,
        pagingType: "simple_numbers",//除首页、上一页、下一页、末页四个按钮还有页数按钮
        stateSave: true,//刷新时是否保存状态
        autoWidth: true,//自动计算宽度
        orderMulti: true,
        pageLength: 10,
		"ajax" : {
			"type": "POST",
			"url": rootPath + '/user/getIntegralHistory',
			"dataType":'json',
			"contentType": "application/json",
			"data": function ( data ) {
				return JSON.stringify(data);
			},
		    error:function(){
		    }
         
		},
		"columns" : [ 
		{
			"name" : "cts",
			"data" : "cts"
		}, 
		{
			"name" : "name",
			"data" : "name"
		},
		{
			   "name" : "increaseIntegral",
			   "data" : "increaseIntegral",
			   "render" : function(data, type, row, meta) {
			    return data>0? "+" + data : data;
			   }
		},
		{
			"name" : "comment",
			"data" : null,
			"render" : function(data, type, row, meta) {
				let dateNode = new Date("2018-11-15");
				let myDate = new Date(data.cts);
				if(myDate < dateNode){
					return "/";
				} else {
					 return data.comment;
				}
			   
			 }
		}
		
		 ]
	});
});